home *** CD-ROM | disk | FTP | other *** search
- #import <objc/Object.h>
- #import <sys/param.h>
-
- typedef struct {
- char fullpath[MAXPATHLEN];
- char type[MAXPATHLEN];
- } Type;
-
- @interface NXBitmapImageRepControl : Object
- {
- int typesCount; // number of convertor typers
- int curMax; // current maximum # of types. Grow dynamically
- Type **types; // Dyanmic array of covnerter types and locations on disk
- Type *curType ; // If one is linked, current type converter, otherwise, NULL
- BOOL useNeXTStep; // This variable controls the use of the window manger
-
- id myView; // View used in save panel.
- BOOL amSaving; // Used to figure out what custom converter view to use.
- id currentPanel; // Used to message the current panel.
- id myBox; // Holds my custom view in save panel.
- NXRect viewDefault; // Default size of my ViewRect.
- id mySubView; // Used to handle converters sub view in save panel.
- id panelSave; // Used so I can pass the save panel around methods
- id myPopUp; // Pop up for save panel.
- id myButton; // Button that holds pop.
- id nameText; // Used to display format name in Save Panel.
- char picName[MAXPATHLEN]; // Holds nams of file currently being saved.
- }
-
- /*
- * Initializes object and scans for converters
- */
- - init;
-
- /*
- * Deals with linking the correct convertor off of disk.
- * Assumes: Object has been initialized with a message to init and that inType
- * is a null terminated pointer to a convertor type that exists in the
- * convertor list. This list can be accessed via a message to getTypeList.
- * a filename will have the correct type if it was received via the
- * runOpenPanel method.
- * Returns: self
- */
- - handleLink: (char *)inType;
-
- /*
- * Runs the open panels. Returns whatever the openPanel object's
- * runModalForTypes method returns. All filetypes found during init
- * will be valid.
- * Assumes: Object has been initialized with message to init.
- * Returns: See OpenPanel.
- */
- - (int)runOpenPanel: (id)openPanel;
-
- /*
- * Looks at the extension on file filename, links the correct convertor, and
- * loads the image, returning an NXBitmapImageRep.
- * Assumes: Object initialized with message to init. filename exists on
- * disk.
- * Returns: Id to NXBitmapImageRep on success, or nil on failure.
- */
- - (id)openAndReturnImage: (const char *)filename;
-
- /*
- * Gets the long name for the currently linked format convertor. This is
- * useful if you say want the user to read Tagged Image File Format
- * rather than just tiff.
- * Assumes: Object inited and a convertor has been linked. This is
- * Usually accomplished with either a save or open.
- * Returns: A pointer to a string containing the format name.
- */
- - (char *)getCurrentFormatName;
-
- /*
- * Runs the save panel for valid types. This also deals with linking in
- * the custom views of the converters and selected different save types.
- * note that after this panel is run, the saveImage method should ne
- * called, otherwise user settings may be forgotten.
- * Assumes: Object initialized via init message.
- * Returns: 0 if cancel clicked.
- */
- - (int)runSavePanel: (id)savePanel withFilename: (const char *)filename;
-
- /*
- * Saves "image" named "filename" to disk. Via the correct convertor. The
- * convertor was selected via use of the runSavePanel methods, so this
- * methods should be called immediately afterward, as they're used in sync
- * with each other.
- * Assumes: Object has been initialized and runSavePanel was the last
- * message to this object instance.
- * Returns: YES is object correctly save, NO otherwise.
- */
- - (BOOL)saveImage: (id)image toFile: (const char *)filename;
-
- /*
- * Give you the filetype list found when object was initialized.
- * Assumes: Object has been initialized with a call to init.
- * Returns: Returns a NULL terminated list of pointers to NULL
- * terminated strings. This can be passed directly into
- * the open panel, for example.
- */
- - (char **)getTypeList;
-
- /*
- * Gets the most recently linked convertor.
- * Assumes: Object initialized via message to init and that a convertor has
- * been linked by a message to runSavePanel, handleLink, or
- * openAndReturnImage.
- * Returns: id of linked convertor.
- * Notes: Return is only a pointer to the id. The object will no longer remain
- * valid after the next link. Also note that it's not recommended to go
- * go around the save and open methods provided. Calls such as this
- * one exist primarily for people that need access to special stream
- * types, and not just filenames.
- */
- - getCurrentConverter;
-
- /*
- * Methods for converters to call.
- */
-
- /*
- * Gets an image control instance. This returned object can be used to
- * perform basic image adjustments like converting Color to B&W or
- * color to 1 bit B&W. See it's header file for details.
- * Assumes: "image" is a valid NXBitmapImageRep, or ancestor thereof.
- * Returns: id of image control object.
- */
- - getImageControl: (id)image;
-
- /*
- * Reports the name of the currently selected file for saving.
- * Assumes: runSavePanel has been messaged. Also, assumes you
- * will not modify filename or try and free the pointer returned.
- * It will remain valid until the next call to runSavePanel, so
- * you might wish to make a copy.
- * Returns: A pointer to a null terminated string containing a filename.
- */
- - (char *)filename;
-
- /*
- * Sets whether or not the control object should attempt to use the window manager.
- * This will be over ridden, under the current release, by functions that intuitively depend
- * on the use of windows, such as the save panel. This may or may not be changed in
- * a future release. However, all error messages will print to stderr when controller is
- * told to not use the window manager. The default value is YES.
- * Assumes: Object instantiated
- * Results: If YES, then the window manager must be running. If NO, running the
- * window manager is optional. In the event that it is not, the converter
- * will core dump.
- */
- - setUseNeXTStep: (BOOL)state;
-
- /*
- * Returns whether or not the object will use the window manager.
- * Assumes: Object instantiated.
- * Returns: YES, the object will use the window manager, or NO, the object will
- * use stderr error for messages.
- */
- - (BOOL)usesNeXTStep;
-
- - (int)errorState;
-
- - (int)errorMessage;
-
- @end
-